package senpec.qc.harmony.base.utils;

import java.util.List;

public class StringUtil {

    public static String getExtensionName(String originalFilename) {
        boolean contains = originalFilename.contains(".");
        if (!contains) {
            throw new RuntimeException("文件名不规范");
        }
        String[] split = originalFilename.split("\\.");
        return split[split.length - 1];
    }

    public static Boolean equals(Character c1, Character c2) {
        return c1.equals(c2);
    }

    public static Boolean equals(String s1, String s2) {
        return s1.equals(s2);
    }

    public static Boolean notEquals(Character c1, Character c2) {
        return !c1.equals(c2);
    }

    public static Boolean notEquals(String s1, String s2) {
        return !s1.equals(s2);
    }

    public static String arrayToString(String[] array) {
        if (array == null || array.length == 0) {
            return null;
        }
        StringBuilder sb = new StringBuilder();
        int i = 0;
        for (String s : List.of(array)) {
            sb.append(s).append(",");
            i++;
        }
        if (i > 0) {
            sb.deleteCharAt(sb.length() - 1);
        }
        return sb.toString();
    }

    public static String[] stringToArray(String str) {
        if (str == null || str.isEmpty()) {
            return null;
        }
        return str.split(",");
    }

    public static String getFullTestMethodName(String method) {
        return switch (method) {
            case "RT" -> "射线检测";
            case "UT" -> "超声检测";
            case "CH" -> "超声测厚";
            case "MT" -> "磁粉检测";
            case "PT" -> "渗透检测";
            case "ET" -> "涡流检测";
            case "LT" -> "泄漏检测";
            case "VT" -> "目视检测";
            default -> "其它检测";
        };
    }

}